package ps.client.gui.dpsoverlay;

import javax.swing.DefaultListModel;

import ps.net.DpsParseContent;


@SuppressWarnings("serial")
public class DpsListModel extends DefaultListModel {
    
    DpsListEntry[] entries = new DpsListEntry[0];
    
    @Override
    public Object getElementAt(int index) {
        DpsListEntry ret = null;
        try {
            ret = entries[index];
        } catch (Exception ex) {
        }
        return ret;
    }
    
    public void setData(DpsParseContent content) {
        entries = content.getDpsListEntries();
        
//        int endIndex = entries.length > 0 ? entries.length - 1 : 0;
//        fireContentsChanged(this, 0, endIndex);
        fireContentsChanged(this, 0, entries.length);
    }
    
    @Override
    public void clear() {
        entries = new DpsListEntry[0];
        fireContentsChanged(this, 0, 0);
    }
    
    @Override
    public int getSize() {
        return entries.length;
    }
}
